package org.csu.jpetstore_users_backend_pj.config;

import org.csu.jpetstore_users_backend_pj.interceptors.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

//指示一个类声明了一个或多个@Bean方法，并且可能会被Spring容器用来生成Bean定义和服务请求。
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    public LoginInterceptor loginInterceptor;

    //使用数组存放路径
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册拦截器 但是登陆注册接口不拦截
        registry.addInterceptor(loginInterceptor)
                .excludePathPatterns(
                        "/tokens","/username","/index","/categories",
                        "/categories/{categoryId}/products","/products/{productId}/items",
                        "/items/{itemId}","/catalog/productAuto","/infoWindowCategory/{categoryId}",
                        "/users", "/usernameIsExist","/phoneIsExist","/emailIsExist",
                        "/captcha","/SignOnByPhone"
                );
    }
}
